public class Test {
    public static void main(String[] args) {
        /*String filename = "file.docx";
        String caselsh = filename.substring(0,filename.lastIndexOf("."));
        System.out.println(caselsh);*/

        String filename = "file.txt";// 文件名
        String[] strArray = filename.split("\\.");
        int suffixIndex = strArray.length -1;
        System.out.println(strArray[suffixIndex]);

    }
}
